package com.future.ssm.controller;

import com.future.ssm.dto.NewsDTO;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;

/**
 * 新闻舆情控制器
 *
 * @author shiyong
 * 2020/12/22 16:48
 */
@RestController
@RequestMapping("/news")
public class NewsController {

    /**
     * 获取新闻列表
     *
     * @return java.util.List<com.future.ssm.dto.NewsDTO>
     * @author shiyong
     * 2020/12/21 9:31
     */
    @RequestMapping("/getNewsList")
    public List<NewsDTO> getNewsList() {
        List<NewsDTO> newsList = new ArrayList<>();

        NewsDTO news = new NewsDTO();
        news.setNewsId("11111");
        news.setTitle("全国大部气温回升 华北等地将现中度霾");
        news.setSource("中国天气网");
        news.setReleaseDate(LocalDate.now());
        newsList.add(news);

        return newsList;
    }

    @RequestMapping("/getNewsDetail")
    public NewsDTO getNewsDetail(NewsDTO newsDTO) {
        System.out.println(newsDTO.toString());

        NewsDTO news = new NewsDTO();
        news.setNewsId("11111");
        news.setTitle("全国大部气温回升 华北等地将现中度霾");
        news.setSource("中国天气网");
        news.setReleaseDate(LocalDate.now());

        return news;
    }

}
